﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities.PBCM;

namespace WindowsForms.PBCM
{
    public partial class FormThemChiTietThietBi : Form
    {
        public FormThemChiTietThietBi()
        {
            InitializeComponent();
        }

        private void textBoxSL_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void textBoxTT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void buttonThem_Click(object sender, EventArgs e)
        {
           

            try
            {
                ChiTietThietBi a = new ChiTietThietBi();
                a.MaChiTietThietBi = textBoxMaCTTB.Text;
                a.MaThietBi = textBoxMaBT.Text;
                a.SoLuong = Convert.ToInt32(textBoxSL.Text);
                a.TinhTrang = Convert.ToInt32(textBoxTT.Text);
                a.NgayCapNhat = dateTimePicker1.Value;
                if (ChiTietThietBi.Objects.Add(a))
                {
                    MessageBox.Show("Thêm thành công");
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Thêm không thành công, nhập lại");

            }
        }
    }
}
